
package jpoco.client;

import java.io.*;
import java.util.List;

import jpoco.io.Deserializer;


public class Util
{
	static public <T extends Response> T loadResponse(InputStream input, Format fmt, Class<? extends Response> responseClass)
	{
		Deserializer des = new Deserializer(fmt, responseClass);
		Response r = des.deserialize(input, responseClass);
		
		return (T) r;
	}
	
	static public String toString(String description, List<Object> values)
	{
		if ( (values == null) || (values.size() == 0) )
		{
			return "";
		}
		else
		{
			StringBuilder sb = new StringBuilder();
			sb.append(description);
			sb.append(":");
			for (Object value : values)
			{
				sb.append(" ");
				sb.append(String.valueOf(value));
			}
			sb.append("\n");
			return sb.toString();
		}
	}
	
}
